import React from 'react'
import ReactDOM from 'react-dom'

import App from './App'
import { BrowserRouter, Switch, Route, Redirect } from 'react-router-dom'
//主页和404页
import { subordination } from './routes'


ReactDOM.render(
    <BrowserRouter>
        <Switch>
            {
                subordination.map(item => {
                    return (
                        <Route path={item.pathname} render={(routerPorps) => {
                            return <item.component {...routerPorps} />
                        }} key={item.pathname} />
                    )
                })
            }
            <Route path={'/admin'} render={(routerPorps) => {
                return <App {...routerPorps} />
            }} />
            <Redirect to={'/admin'} from={'/'}></Redirect>
            <Redirect to={'/404'} from={'/'} ></Redirect>

        </Switch>
    </BrowserRouter>

    , document.getElementById('root'))

